#ifndef _VFX_EXPLOSION_H_
#define _VFX_EXPLOSION_H_

#include "math/vec2.h"
#include "math/vec4.h"
#include "sfx.h"
#include "math/counter.h"
#include "ui/ui_sprite.h"
class Image;
class Graphics;

namespace vfx
{

class	Explosion
{
public:
	struct	Node
	{	
		math::Vec2	Pos;
		float		Time;
		float		Radius;
		bool		Free;
	};	

					Explosion(int Count, const std::string& Image, bool additive, float Timeout);
					~Explosion();
	void			Render(const math::Vec2& Pos, float Scale, float Radius, float Progress);
	void			Render(const math::Vec2& Offset, float Scale);
	void			AddExplosion(const math::Vec2& Pos, float Radius);
private:
	float			m_Timeout;
	Image*			m_pImage;
	bool			m_Additive;
	
	int				m_Count;
	int				m_ActiveC;
	Node*			m_NodeA;

	void			SetupRenderState(Graphics* pG);
	void			RestoreRenderState(Graphics* pG);
};

class	ExplosionSet: public SFXSet
{
public:
	struct						Explosion
	{
		math::Counter			Time;
		math::Vec2				Pos;
		float					FromRad, ToRad;
	};

	ExplosionSet(EffectMan*	pParent, const std::string& Image, int Count, const math::Vec4& From=math::Vec4(0,0,0,0), const math::Vec4& To=math::Vec4(1,1,1,1));
	virtual						~ExplosionSet();
	virtual	void				Render(const math::Vec2& Offset, float Scale);
	virtual void				Tick(float dt);
	void						Trigger(const math::Vec2& Pos, float Time, float FromR, float ToR);
protected:
	virtual void				Load(const std::string& Image, int Count, const math::Vec4& From, const math::Vec4& To);
	ui::UISprite				m_Sprite;
	Explosion*					m_ExplosionA;
	math::Vec4					m_From, m_To;
	int							m_ExpUsed, m_ExpC;
};

}  // namespace vfx




#endif // _VFX_EXPLOSION_H_